<?php

namespace App\Modules\Apicrzs\Services\Water;

use App\Modules\Admin\Entities\Expenses\CouponModel;
use App\Modules\Admin\Entities\Property\WaterCouponModel;
use App\Modules\Apicrzs\Entities\UserScoreModel;
use App\Modules\Apicrzs\Services\BaseServices;
use App\Traits\CryptAES;

class CouponService extends BaseServices
{
    public function __construct(WaterCouponModel $model)
    {
        $token =  \request()->header('token');
        $user_info = CryptAES::decryptToken($token,'user_grzq');
//
        $this->user_id = $user_info['data']['user_id']??"";
        $this->model = $model;
        $this->userScoreModel = new UserScoreModel();
    }
    /**
     * @param $params type 1 卡券 ，2 套餐
     * @return mixed
     */
    public function getLists($params){

        $type = $params['type']??1;
        $res = $this->model
            ->where(['type'=>$type,'status'=>"Y",'is_delete'=>0,'is_user'=>'Y','status'=>'Y'])
            ->orderBy('sort', 'desc')
            ->get()->toArray();
        return $res;
    }
}
